﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.WSA.Application
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System.Runtime.CompilerServices;
using UnityEngine.Bindings;
using UnityEngine.Scripting;

#nullable disable
namespace UnityEngine.WSA
{
  /// <summary>
  ///   <para>Provides essential methods related to Window Store application.</para>
  /// </summary>
  [NativeHeader("Runtime/Export/WSA/WSAApplication.bindings.h")]
  [StaticAccessor("WSAApplicationBindings", StaticAccessorType.DoubleColon)]
  public sealed class Application
  {
    public static event WindowSizeChanged windowSizeChanged;

    public static event WindowActivated windowActivated;

    /// <summary>
    ///   <para>Arguments passed to application.</para>
    /// </summary>
    public static string arguments => Application.GetAppArguments();

    /// <summary>
    ///   <para>Advertising ID.</para>
    /// </summary>
    public static string advertisingIdentifier
    {
      get
      {
        string advertisingIdentifier = Application.GetAdvertisingIdentifier();
        UnityEngine.Application.InvokeOnAdvertisingIdentifierCallback(advertisingIdentifier, true);
        return advertisingIdentifier;
      }
    }

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern string GetAdvertisingIdentifier();

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern string GetAppArguments();

    [RequiredByNativeCode]
    internal static void InvokeWindowSizeChangedEvent(int width, int height)
    {
      if (Application.windowSizeChanged == null)
        return;
      Application.windowSizeChanged(width, height);
    }

    [RequiredByNativeCode]
    internal static void InvokeWindowActivatedEvent(WindowActivationState state)
    {
      if (Application.windowActivated == null)
        return;
      Application.windowActivated(state);
    }

    /// <summary>
    ///   <para>Executes callback item on application thread.</para>
    /// </summary>
    /// <param name="item">Item to execute.</param>
    /// <param name="waitUntilDone">Wait until item is executed.</param>
    public static void InvokeOnAppThread(AppCallbackItem item, bool waitUntilDone) => item();

    /// <summary>
    ///   <para>Executes callback item on UI thread.</para>
    /// </summary>
    /// <param name="item">Item to execute.</param>
    /// <param name="waitUntilDone">Wait until item is executed.</param>
    public static void InvokeOnUIThread(AppCallbackItem item, bool waitUntilDone) => item();

    [ThreadAndSerializationSafe]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern void InternalInvokeOnAppThread(object item, bool waitUntilDone);

    [ThreadAndSerializationSafe]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern void InternalInvokeOnUIThread(object item, bool waitUntilDone);

    /// <summary>
    ///   <para>Returns true if you're running on application thread.</para>
    /// </summary>
    [ThreadAndSerializationSafe]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public static extern bool RunningOnAppThread();

    /// <summary>
    ///   <para>Returns true if you're running on UI thread.</para>
    /// </summary>
    [ThreadAndSerializationSafe]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public static extern bool RunningOnUIThread();
  }
}
